Skip to content

fix: docker availability precheck#596

Open
CKodidela wants to merge 8 commits intocameri:mainfrom
CKodidela:fix/docker-availability-precheck
Open

fix: docker availability precheck#596
CKodidela wants to merge 8 commits intocameri:mainfrom
CKodidela:fix/docker-availability-precheck

Conversation

@CKodidela
Copy link
Copy Markdown
Collaborator

Description

Replaces the per-call-site try/catch in getRelayUptimeSeconds with a normalized result type on runCommandWithOutput. The
function now always resolves with a CommandResult discriminated union instead of rejecting on spawn errors, giving every caller
a consistent contract.

Related Issue

Closes #590

Motivation and Context

spawn emits an ENOENT error (not a non-zero exit code) when the target command is not installed. Before this change,
runCommandWithOutput forwarded that rejection to callers, which caused info --json to crash when Docker was absent. The
short-term fix was a try/catch at the call site, but the same class of bug could recur in any other wrapper.

The fix moves the concern into the shared runner so all callers benefit automatically.

How Has This Been Tested?

  • Added a regression test (outputs valid JSON when docker is not installed (ENOENT)) that stubs runCommandWithOutput to
    return { ok: false, reason: 'not-found' } and asserts info --json still exits 0 with valid JSON.
  • Updated all existing stubs in info.spec.ts and update.spec.ts to use the new CommandResult shape.
  • All 67 unit tests pass (npm run test:cli).

Types of changes

  • Non-functional change (docs, style, minor refactor)
  • Bug fix (non-breaking change which fixes an issue)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my code changes.
  • I added a changeset, or this is docs-only and I added an empty changeset.
  • All new and existing tests passed.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 2, 2026

🦋 Changeset detected

Latest commit: 2afa875

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
nostream Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@CKodidela CKodidela changed the title Fix/docker availability precheck fix: docker availability precheck May 2, 2026
@coveralls
Copy link
Copy Markdown
Collaborator

coveralls commented May 2, 2026

Coverage Status

coverage: 64.85% (-0.3%) from 65.131% — CKodidela:fix/docker-availability-precheck into cameri:main

@CKodidela
Copy link
Copy Markdown
Collaborator Author

@cameri up for review

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR normalizes runCommandWithOutput so CLI commands receive a discriminated CommandResult instead of handling spawn-time rejections ad hoc. In the CLI codebase, that mainly addresses Docker/Git availability failures more consistently and adds regression coverage for the info --json Docker-missing case.

Changes:

  • Added a CommandResult union to runCommandWithOutput and converted spawn/timeout/signal failures into resolved results.
  • Updated info and update command paths to handle the new result shape.
  • Added/updated CLI tests for the new contract, including a regression test for Docker missing in info --json.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/cli/utils/process.ts Changes the command runner contract from reject-on-spawn-error to resolved union results.
src/cli/commands/info.ts Updates relay uptime lookup to handle CommandResult.ok.
src/cli/commands/update.ts Adds handling for git stash spawn failures during update flow.
test/unit/cli/run-command.spec.ts Adds direct tests for the new runCommandWithOutput result variants.
test/unit/cli/info.spec.ts Updates stubs to new shape and adds Docker-missing JSON regression coverage.
test/unit/cli/update.spec.ts Updates existing stubs to the new CommandResult shape.
.changeset/normalize-run-command-with-output.md Records the patch release note for the CLI runner contract change.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/cli/utils/process.ts
options: RunOptions = {},
): Promise<{ code: number; stdout: string; stderr: string }> => {
return new Promise((resolve, reject) => {
): Promise<CommandResult> => {
Comment on lines +22 to 26
spinner.fail(stashResult.ok === false && stashResult.reason === 'not-found' ? 'Update failed: git is not installed' : 'Update failed while stashing local changes')
return 1
}
if (stashResult.code !== 0) {
spinner.fail('Update failed while stashing local changes')
Comment on lines +21 to +23
if (!stashResult.ok) {
spinner.fail(stashResult.ok === false && stashResult.reason === 'not-found' ? 'Update failed: git is not installed' : 'Update failed while stashing local changes')
return 1
@CKodidela
Copy link
Copy Markdown
Collaborator Author

will resolve this soon

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Discuss alternatives for getRelayUptimeSeconds error handling

4 participants